Skip to content

feat: Implement FuncDoTaskBuilder to also cover raise and tryCatch#1322

Draft
matheusandre1 wants to merge 2 commits intoserverlessworkflow:mainfrom
matheusandre1:feature/1304
Draft

feat: Implement FuncDoTaskBuilder to also cover raise and tryCatch#1322
matheusandre1 wants to merge 2 commits intoserverlessworkflow:mainfrom
matheusandre1:feature/1304

Conversation

@matheusandre1
Copy link
Copy Markdown
Contributor

Many thanks for submitting your Pull Request ❤️!

What this PR does / why we need it: draft to Closes: #1304

Special notes for reviewers:

Additional information (if needed):

@matheusandre1
Copy link
Copy Markdown
Contributor Author

take a look, @domhanak....

@mcruzdev
Copy link
Copy Markdown
Collaborator

mcruzdev commented Apr 21, 2026

Hi @matheusandre1 is this ready for review?

@matheusandre1 matheusandre1 marked this pull request as ready for review April 21, 2026 04:01
@matheusandre1 matheusandre1 requested a review from fjtirado as a code owner April 21, 2026 04:01
Copilot AI review requested due to automatic review settings April 21, 2026 04:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the experimental FuncWorkflowBuilder / FuncDoTaskBuilder fluent API so function-based workflows can include raise() and tryCatch() tasks (per #1304), avoiding the need to fall back to JQ for these constructs.

Changes:

  • Add raise(...) and tryCatch(...) support to the func “do” fluent surface (FuncDoFluent, FuncDoTaskBuilder, FuncTaskItemListBuilder) and provide matching FuncDSL helpers.
  • Introduce FuncRaiseTaskBuilder and FuncTryTaskBuilder to build the corresponding spec task structures.
  • Add a JUnit test validating raise and try/catch compilation through FuncWorkflowBuilder.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
experimental/fluent/func/src/test/java/io/serverlessworkflow/fluent/func/FuncDSLTest.java Adds coverage ensuring raise and tryCatch tasks are emitted correctly via FuncWorkflowBuilder.
experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/spi/FuncDoFluent.java Extends the func “do” fluent interface to include raise and try/catch task fluent APIs.
experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/dsl/FuncDSL.java Adds FuncDSL.raise(...) and FuncDSL.tryCatch(...) task configurer helpers.
experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/FuncTryTaskBuilder.java New builder for try/catch tasks (try handler + catch handler + retry/errors/backoff helpers).
experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/FuncTaskItemListBuilder.java Implements list-level raise and tryCatch task appenders.
experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/FuncRaiseTaskBuilder.java New builder for raise tasks.
experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/FuncDoTaskBuilder.java Wires raise and tryCatch through the workflow “do” builder to the underlying list builder.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Matheus Andre <matheusandr2@gmail.com>
Signed-off-by: Matheus André <matheusandr2@gmail.com>
Copy link
Copy Markdown
Collaborator

@mcruzdev mcruzdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks great @matheusandre1, please, could you add a test that demostrate a workflow running? Inside src/test/java/io/serverlessworkflow/fluent/test?

@mcruzdev
Copy link
Copy Markdown
Collaborator

Why src/test/java/io/serverlessworkflow/fluent/test? I didn't understand

Where we are testing all the FuncDSL methods

Copilot AI review requested due to automatic review settings April 21, 2026 22:13
Signed-off-by: Matheus André <matheusandr2@gmail.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +31 to +40
public class FuncRaiseTaskBuilder extends TaskBaseBuilder<FuncRaiseTaskBuilder>
implements FuncTaskTransformations<FuncRaiseTaskBuilder>,
ConditionalTaskBuilder<FuncRaiseTaskBuilder> {

private final RaiseTask raiseTask;

FuncRaiseTaskBuilder() {
this.raiseTask = new RaiseTask();
setTask(this.raiseTask);
}
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Optional) FuncRaiseTaskBuilder closely mirrors fluent/spec RaiseTaskBuilder. This duplication can make future spec-aligned changes easy to miss in one place. If feasible, consider refactoring so the func DSL reuses the spec builder implementation (e.g., by sharing a common base/helper or making the spec builder constructor extensible).

Copilot uses AI. Check for mistakes.
Comment on lines +43 to +52
public class FuncTryTaskBuilder extends TaskBaseBuilder<FuncTryTaskBuilder>
implements FuncTaskTransformations<FuncTryTaskBuilder>,
ConditionalTaskBuilder<FuncTryTaskBuilder> {

private final TryTask tryTask;

FuncTryTaskBuilder() {
this.tryTask = new TryTask();
setTask(this.tryTask);
}
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Optional) FuncTryTaskBuilder largely duplicates fluent/spec TryTaskBuilder (including nested retry/backoff/catch builders). This increases maintenance overhead and the risk of behavior drifting between spec and func DSL over time. If practical, consider extracting shared helpers/builders or refactoring to reuse the spec builder implementation so both stay in sync.

Copilot uses AI. Check for mistakes.
@matheusandre1
Copy link
Copy Markdown
Contributor Author

matheusandre1 commented Apr 21, 2026

@mcruzdev , Ignore review copilot or can I do this refactor?

@matheusandre1 matheusandre1 marked this pull request as draft April 21, 2026 23:08
@mcruzdev
Copy link
Copy Markdown
Collaborator

@mcruzdev , Ignore review copilot or can I do this refactor?

I think it makes sense, we can have something like we have for FuncForkTaskBuilder having an AbstractForkTaskBuilder, TAL: #1302

@matheusandre1
Copy link
Copy Markdown
Contributor Author

I'm doing something similar, I'll send it shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Implement FuncDoTaskBuilder to also cover raise() and tryCatch()

3 participants